String vs Array concat
JavaScript performance comparison
Preparation code
<script>
Benchmark.prototype.setup = function() {
var precompiled = 'apple';
while (precompiled.length < 100) {
var offs = precompiled.length - 5;
for (var i = offs; i < offs + 10; ++i) {
// calling charAt(i) on `precompiled` will
// flatten the string in most engines
precompiled += precompiled.charAt(i);
}
}
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
Test | Ops/sec | |
---|---|---|
String
|
|
pending… |
String w/o flattening
|
|
pending… |
String w/o flattening by index (IE > 7)
|
|
pending… |
Array
|
|
pending… |
Compare results of other browsers
Revisions
You can edit these tests or add even more tests to this page by appending /edit
to the URL.
- Revision 1: published Corey Schram
- Revision 2: published and last updated
- Revision 9: published
- Revision 10: published
- Revision 11: published
- Revision 12: published
- Revision 13: published
- Revision 14: published
- Revision 15: published
- Revision 16: published greg
- Revision 17: published
- Revision 18: published
0 Comments